package com.yj.springbootevent.event;

import com.yj.springbootevent.dto.UserDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;


/**
 * 事件监听器
 */
@Slf4j
@Component
@Order(1)
public class MyListener implements ApplicationListener<MyApplicationEvent> {
    @Override
    public void onApplicationEvent(MyApplicationEvent myApplicationEvent) {
        UserDto userDto = myApplicationEvent.getUserDto();

        log.info("获取到的数据：{}",userDto);

        sendMail(userDto);
    }

    private void sendMail(UserDto userDto) {
        log.info("sendMail:{}",userDto);
    }
}
